/*
 * Copyright (c) 2017. 深圳掌控网络有限公司. All rights reserved.
 */

package com.yiqi.lottery.feature.find.presenter;

import com.suozhang.framework.entity.bo.PageData;
import com.yiqi.lottery.entity.bo.CircleBo;
import com.yiqi.lottery.entity.bo.FindScoreBo;
import com.yiqi.lottery.feature.find.contract.CircleContract;
import com.yiqi.lottery.feature.find.contract.LiveContract;
import com.yiqi.lottery.feature.find.dependencies.circle.DaggerCirclePresenterComponent;
import com.yiqi.lottery.feature.find.dependencies.live.DaggerLivePresenterComponent;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

import javax.inject.Inject;

/**
 *      LIJUWEN
 * @email yiyayiyayaoljw@gmail.com
 * @date 2017/4/11 9:31
 */
public class LivePresenter implements LiveContract.Presenter {

    private LiveContract.View mView;

    @Inject

    LiveContract.Model mModel;


    public LivePresenter(LiveContract.View mView) {
        this.mView = mView;
        DaggerLivePresenterComponent.create().inject(this);
    }

    @Override
    public void start() {

    }


    @Override
    public void getScoreLive(int type) {
        mModel.getScoreLive(type).compose(mView.bindToLife()).subscribe(new Observer<FindScoreBo>() {
            @Override
            public void onSubscribe(Disposable d) {
                mView.showLoading(d);
            }

            @Override
            public void onNext(FindScoreBo s) {
                mView.showScoreSuccess(s);
                mView.dismissLoading();
            }

            @Override
            public void onError(Throwable e) {
                mView.showScoreLiveError(e.getMessage());
                mView.dismissLoading();
            }

            @Override
            public void onComplete() {
                mView.dismissLoading();
            }
        });
    }
}
